﻿
// MFCApplication1Dlg.h: 头文件
//

#pragma once
#include "../public/xpackSupports.h"
#include "CMBWnd.h"
#include "EasySize.h"

#include <string>
#include <thread>
#include <xpack/json.h>

// CMFCApplication1Dlg 对话框
class CMFCApplication1Dlg final : public CDialog
{
    // 构造
  public:
    explicit CMFCApplication1Dlg(std::wstring url, CWnd *pParent = nullptr); // 标准构造函数

// 对话框数据
#ifdef AFX_DESIGN_TIME
    enum
    {
        IDD = IDD_MFCAPPLICATION1_DIALOG
    };
#endif

  protected:
    virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV 支持

    // 实现
  protected:
    HICON m_hIcon;

    // 生成的消息映射函数
    virtual BOOL OnInitDialog();
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg LRESULT OnLoadedData(WPARAM wParam, LPARAM lParam);
    afx_msg void OnDestroy();
    DECLARE_MESSAGE_MAP()
    DECLARE_EASYSIZE
    void LoadData();

  private:
    CMBWnd m_mbWin;
    std::wstring m_url;

    struct FormData
    {
        double contral_point_step;
        double total_area;
        double precision_level;
        int direction;
        int mode;
        bool is_point_cloud;
        XPACK(M(contral_point_step, total_area, precision_level, direction, mode, is_point_cloud));
    } m_lastInputData, m_formData;
    std::thread m_loadData;
    void LoadURL();
    void BindFunctions();
    static jsValue WKE_CALL_TYPE jsInitData(jsExecState es, void *vptr);
    static jsValue WKE_CALL_TYPE jsOnOk(jsExecState es, void *vptr);
    static jsValue WKE_CALL_TYPE jsOnCancel(jsExecState es, void *vptr);
    static jsValue WKE_CALL_TYPE jsLoadData(jsExecState es, void *vptr);
};
